package ro.thich.alchemy;

import android.app.*;
import android.content.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public class MainActivity extends Activity
{
	Button item1;
	Button item2;
	Intent i;
	Bundle bundle;
	static String unu;
	static String doi;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
	{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
		item1 = (Button) findViewById(R.id.item1);
		item2 = (Button) findViewById(R.id.item2);
		i = new Intent(this, ElementActivity.class);
		bundle = getIntent().getExtras();
		if (bundle == null) {
			Toast.makeText(getApplicationContext(), "Eroare bundle!", Toast.LENGTH_SHORT).show();
		}
		else {
			if (bundle.containsKey("unu")){
				unu = bundle.getString("unu");
			}
			else if (bundle.containsKey("doi")){
				doi = bundle.getString("doi");
			}
		}
		item1.setText(unu);
		item2.setText(doi);
    }
	
	public void item_add1(View v)  {  
		i.putExtra("btn", "unu");
		startActivity(i);  
	}
	public void item_add2(View v)  {  
		i.putExtra("btn", "doi");
		startActivity(i);  
	}
	
	public void combina(View v)  {  
		//startActivity(new Intent(this, second.class));  
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle("Element nou"); 
		builder.setMessage("Felicitări!!! Prin combinarea elementelor " + item1.getText() + " și " + item2.getText() + " ai descoperit elementul Abur.");
		builder.setNeutralButton("Ok", new DialogInterface.OnClickListener() { 
				@Override  
				public void onClick(DialogInterface dialog, int which) {  
					// When CenterButton click, source implementing is put here.
				}  
			});    
		builder.show();
	}
}
